<template>
  <div class="tab-control">
    <div class="tab-control-item"
         v-for="(item,index) in titles"
         :class="{active:IndexPointer==index}"
         @click="itemClick(index)"
    >
      <span>{{item}}</span>
    </div>
  </div>
</template>

<script>
  export default {
    name: "TabControl",
    data(){
      return{
        IndexPointer:0,
      }
    },
    props:{
      titles:{
        type:Array,
        default(){
          return []
        }
      },
    },
    methods:{
      itemClick(index) {
        this.IndexPointer=index;
        this.$emit('itemClick',index);

      }
    }

  }
</script>

<style scoped>
  .tab-control{
    display: flex;
    text-align: center;
    font-size: 13px;
    height: 30px;
    padding-top: 5px;
    background-color: #ffffff;

  }
  .tab-control-item{
    flex: 1;
  }
  .active{
    color: red;
  }
  .active span{
    border-bottom: 3px solid #E91E62;
    padding: 5px;
  }
</style>